<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author: LJQ <245369209@qq.com> 
// +----------------------------------------------------------------------

namespace app\basic\model;

/**
 * 危化品
 */
class Danger extends Dangersource{

	protected $sourceType = 2;
	protected $auto = ['sourceType'];

	public function getTypeList(){
		$dangerType = db('basicinfo')->where('sysCode',33)->column('subsystemName','subsystemNo');
		return $dangerType;
	}
	
	public function getTypeIdAttr($value,$data){
		$typeList = $this->getTypeList();
		if($data['typeId']){
			return $typeList[$data['typeId']];
		}
		return null;
	}
	
	public function chemicals(){
		return $this->belongsToMany('Chemical','access_chemical','chemicalId','dangerId');
	}
}